package com.hui.controller;

import com.hui.entity.Product;
import com.hui.entity.ProductVo;
import com.hui.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 李昭辉
 * @Date: 2021/09/26/8:28
 * @Description:
 */
@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private ProductService productService;

    // 保存
    @RequestMapping("/save")
    public String save(@RequestBody Product product) {
        // 保存数据
        productService.save(product);
        return "保存成功";
    }

    // 查询结果
    @RequestMapping("/search")
    public List<Product> search(@RequestBody ProductVo productVo) {

        // 搜索数据
        return productService.search(productVo);
    }


}
